﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Jogo_Grupo2
{
    class Monstro:Objeto2D
    {
        float timer = 0;
        float intervalo = 180f;
        int curframe = 0;
        int spriteWidth;
        int spriteHeight;
        Rectangle spriteRect;

        Monstro monstro;

        List<Monstro> ListaMonstros;

        public Monstro(Texture2D textura, Vector2 posicao)
            : base(textura, posicao)
        {
            spriteWidth = textura.Width / 6;
            spriteHeight = textura.Height;
            spriteRect = new Rectangle(curframe * spriteWidth, curframe * spriteHeight, spriteWidth, spriteHeight);
                
        }

        public void addMonstro()
        {
            monstro = new Monstro(Game1.instancia.Content.Load<Texture2D>("monstro1d"), new Vector2(50, 280));
            ListaMonstros.Add(monstro);
           
        }


        public override void Update(GameTime gameTime)
        {
            timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (curframe >= 5)
                curframe = 0;
            if (timer >= intervalo)
            {
                timer = 0;
                curframe++;
            }
            spriteRect.X = curframe * spriteWidth;
            this.position.X += 1;


            addMonstro();

            base.Update(gameTime);

        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(texture, new Rectangle((int)position.X, (int)position.Y, spriteWidth, spriteHeight), spriteRect, Color.White);

        }



    }
}
